package edu.hrbu.kwaidu.controller;

import edu.hrbu.kwaidu.common.R;
import edu.hrbu.kwaidu.model.entity.SysMenu;
import edu.hrbu.kwaidu.service.SysMenuService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author xudengyu
 * @since 2024-01-02
 */
@RestController
@RequestMapping("/system/sysMenu")
public class SysMenuController {

    @Resource
    private SysMenuService sysMenuService;

    @GetMapping("/getMenuList")
    public R getMenuList(){
        List<SysMenu> menuList=sysMenuService.getMenuList();
        return R.ok(menuList);
    }

    @PostMapping("/addOrEdit")
    public R addOrEdit(@RequestBody SysMenu sysMenu){
        sysMenuService.addOrEdit(sysMenu);
        return R.ok();
    }

    @PostMapping("/del/{id}")
    public R del(@PathVariable("id") Long id){
        sysMenuService.del(id);
        return R.ok();
    }

}
